<!-- 
边框设置 
-->

<template>
  <div class="colStart">
    <div class="rowBetween">
      <div class="rowStart">
        <div class="cLabel">颜色</div>
        <el-color-picker v-model="_widget.style.borderColor" show-alpha></el-color-picker>
      </div>
      <div class="rowStart">
        <div class="cLabel">线宽</div>
        <el-input-number v-model="_widget.style.borderWidth" controls-position="right" style="width: 120px" />
      </div>
    </div>
    <div class="rowStart mt-2" style="align-items: center">
      <div class="cLabel">类型</div>
      <el-radio-group v-model="_widget.style.borderStyle">
        <el-radio value="solid" size="large">实线</el-radio>
        <el-radio value="dashed" size="large">虚线</el-radio>
        <el-radio value="dotted" size="large">点线</el-radio>
      </el-radio-group>
    </div>
    <div class="rowStart mt-2" style="align-items: center">
      <div class="cLabel" style="margin-right: 20px">可见性</div>
      <div style="position: relative; height: 80px">
        <div style="position: absolute; width: 80px">
          <div
            class="cLineW"
            style="position: absolute; left: 0; right: 0"
            v-if="_widget.style.borderPos[0] == 1"
          ></div>
          <div
            class="cLineRectW"
            style="position: absolute; left: 0; right: 0; margin: auto; top: -5px"
            @click="onHideBorder(0)"
          ></div>
        </div>
        <div style="position: absolute; height: 80px; left: 80px">
          <div class="cLineH" style="position: absolute; left: 0" v-if="_widget.style.borderPos[1] == 1"></div>
          <div
            class="cLineRectH"
            style="position: absolute; left: -5px; top: 0; bottom: 0; margin: auto"
            @click="onHideBorder(1)"
          ></div>
        </div>
        <div style="position: absolute; width: 80px; top: 80px">
          <div
            class="cLineW"
            style="position: absolute; left: 0; right: 0"
            v-if="_widget.style.borderPos[2] == 1"
          ></div>
          <div
            class="cLineRectW"
            style="position: absolute; left: 0; right: 0; margin: auto; top: -5px"
            @click="onHideBorder(2)"
          ></div>
        </div>
        <div style="position: absolute; height: 80px; left: 0">
          <div class="cLineH" style="position: absolute; left: 0" v-if="_widget.style.borderPos[3] == 1"></div>
          <div
            class="cLineRectH"
            style="position: absolute; left: -5px; top: 0; bottom: 0; margin: auto"
            @click="onHideBorder(3)"
          ></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import type { TypeWidget } from "@/types/TypeDesign";
import type { PropType } from "vue";

const props = defineProps({
  _widget: {
    type: Object as PropType<TypeWidget>,
    default: () => ({}),
  },
});

const onHideBorder = (index) => {
  if (props._widget.style.borderPos[index] == 0) {
    props._widget.style.borderPos[index] = 1;
  } else {
    props._widget.style.borderPos[index] = 0;
  }
};
</script>

<style lang="scss" scoped>
.cLabel {
  font-size: 14px;
  width: 60px;
  text-align: center;
}

.cLineW {
  width: 80px;
  height: 1px;
  background-color: gray;
}

.cLineH {
  width: 1px;
  height: 80px;
  background-color: gray;
}

.cLineRectW {
  width: 40px;
  height: 10px;
  border: solid 1px gray;
}

.cLineRectH {
  width: 10px;
  height: 40px;
  border: solid 1px gray;
}
</style>
